<!DOCTYPE html>
<html lang="en" class="app"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://rbac.rbacshiro.com"
>

<head th:include="template/top"></head>
<body>
<section class="vbox">
    <header th:include="template/header" class="bg-dark dk header navbar navbar-fixed-top-xs"></header>
    <section>
        <section class="hbox stretch">
            <!-- .aside -->
            <aside th:include="template/menu" class="bg-dark lter aside-md hidden-print" id="nav"></aside>
            <!-- /.aside -->
            <section id="content">
                <section class="vbox">
                    <section class="scrollable padder">
                        <ul class="breadcrumb no-border no-radius b-b b-light pull-in">
                            <li><a href="index.html"><i class="fa fa-home"></i> 首页</a></li>
                            <li class="active">个人中心</li>
                            <li class="active">修改密码</li>
                        </ul>
                        <div class="row">
                            <div class="col-sm-6">
                                <section class="panel panel-default">
                                    <header class="panel-heading font-bold">修改密码</header>
                                    <div class="panel-body">
                                        <form role="form">
                                            <div class="form-group">
                                                <label>密码：</label>
                                                <input type="password" id="rpassword" name="password" class="form-control" placeholder="请输入原始密码" autofocus="autofocus">
                                            </div>
                                            <div class="form-group">
                                                <label>密码：</label>
                                                <input type="password" id="password" name="password" class="form-control" placeholder="请输入密码" data-validation="server" data-validation-url="user/checkPassword" >
                                            </div>
                                            <div class="form-group">
                                                <label>确认密码：</label>
                                                <input type="password" id="tpassword" name="password" class="form-control" placeholder="请再次输入密码" data-validation="server" data-validation-url="user/checkPassword">
                                            </div>
                                            <button type="submit" class="btn btn-sm btn-primary">保&nbsp;存</button>
                                        </form>
                                    </div>
                                </section>
                            </div>
                        </div>
                    </section>
                </section>
                <a href="#" class="hide nav-off-screen-block" data-toggle="class:nav-off-screen" data-target="#nav"></a>
            </section>
            <aside class="bg-light lter b-l aside-md hide" id="notes">
                <div class="wrapper">Notification</div>
            </aside>
        </section>
    </section>
</section>
<script src="js/app.v2.js"></script> <!-- Bootstrap --> <!-- App -->
<script src="layui/lay/dest/layui.all.js" cache="false"></script>
<script src="template-web.js"></script>
<script src="base.js"></script>
<script src="menu.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-form-validator/2.3.26/jquery.form-validator.min.js"></script>
<script>
    $.validate({
        modules : 'security'
    });
    $('form').submit(function(){
        if($('#password').val() !== $('#tpassword').val()) {
            layer.alert("两次输入的密码不一致");
        } else {
            var submitData = $(this).serialize();
            $.ajax({
                url :"admin/change_password",
                data:submitData,
                method:"post",
                dataType:"json",
                success:function(result) {
                    if(result.success) {
                        window.location.reload();
                    } else {
                        layer.msg(result.message);
                    }
                }
            });
        }
        return false;
    });
</script>
</body>

</html>